const PostgresqlConnect = require('@src/db-server/db-connect/postgresql-connect')
const PostgresqlMigrate = require('@src/migrate/postgresql-migrate')
const BuildModel = require('@src/migrate/build-model')

/**
 * 数据库生成models
 * @param {*} data 数据库配置对象
 */
function migrate(data) {
  PostgresqlConnect(data).then(client => {
    PostgresqlMigrate.getAllTable(client).then(tableInfo => {
      client.end()
      BuildModel.buildModel(tableInfo);
    })
  })
}

module.exports = migrate


